//
//  CNDataCommunication.h
//  EkeyPropoganda
//
//  Created by mal on 15/4/21.
//  Copyright (c) 2015年 cnsoft. All rights reserved.
//

#import <Foundation/Foundation.h>

//http请求方式(httpservice,webservice)
typedef enum REQUEST_TYPE {
    HTTP_SERVICE, WEB_SERVICE
}REQUEST_TYPE;

@protocol BIDDataCommunicationDelegate <NSObject>
- (void)connectionCanceled;
@end

@interface BIDDataCommunication : NSObject

@property (copy, nonatomic) NSString *destinationURL;
@property (assign, nonatomic) id<BIDDataCommunicationDelegate> delegate;
@property (copy, nonatomic) void (^completionHandler)(id obj, NSError* err);
@property (assign, nonatomic) REQUEST_TYPE requestType;

+ (BIDDataCommunication*)getInstance;
/**
 *  以同步的方式从后台获取数据，一般多用于登录
 *
 *  @param strURL 请求URL
 *  @param postValue post方式提交的数据
 *
 *  @return
 */
+ (id)getDataFromNetBySyn:(NSString*)strURL postValue:(NSString*)postValue;

+ (int)getDataFromNet:(NSString *)strURL data:(NSMutableData *)desData;

+ (int)getDataWithURL:(NSString *)strURL andPost:(NSString*)postData toDictionary:(NSMutableDictionary *)desDictionary;

- (id)initWithURL:(NSString*)strURL;

//以get方式提交数据
//- (void)getDataFromNet:(NSString*)strURL toDictionary:(NSMutableDictionary *)desDictionary;

//以post方式提交数据
- (NSURLConnection*)getDataFromNet:(NSString*)strURL postValue:(NSString*)postValue completionHandler:(void (^)(id obj, NSError* err))completionHandler1;

@end
